package com.lzl.lazy;

public class LazyDoubleCheckSingleton {
    private  static volatile LazyDoubleCheckSingleton INSTANCE;

    private LazyDoubleCheckSingleton(){}

    /**
     * 双重检查，静态成员变成要加volatile 关键字，让编译时不进行重排序。
     * @return
     */
    public static  LazyDoubleCheckSingleton getInstance(){
        if(null == INSTANCE){
            synchronized (LazyDoubleCheckSingleton.class){
                if(null == INSTANCE){
                    INSTANCE = new LazyDoubleCheckSingleton();
                }
            }
        }
        return INSTANCE;
    }

}
